package books

import "encoding/json"

type Book struct {
	Title  string
	Author string
	Pages  int
}

func (book *Book) CategoryByLength() string {
	if book.Pages > 1000 {
		return "NOVEL"
	}
	return "SHORT STORY"
}

func NewBookFromJSON(s string) (book Book, err error) {
	err = json.Unmarshal([]byte(s), &book)
	return
}
